package com.bubbles.workspace.sync.repository.source.constraint;


import com.bubbles.engine.data.core.repository.BaseRepository;
import com.bubbles.workspace.sync.entity.source.constraint.SourceIndexUnique;
import com.bubbles.workspace.sync.key.source.constraint.SourceIndexKey;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>description: 源数据源-唯一索引 </p>
 *
 * @author CryptoNeedle
 * @date 2025-06-20
 */
@Repository
public interface SourceIndexUniqueRepository extends BaseRepository<SourceIndexUnique, SourceIndexKey> {
    
    @Query("FROM SourceIndexUnique WHERE sourceCatalogName = :sourceCatalogName")
    List<SourceIndexUnique> listByCatalog(String sourceCatalogName);
    
    @Query("FROM SourceIndexUnique WHERE sourceCatalogName = :sourceCatalogName AND sourceDatabaseName = :sourceDatabaseName")
    List<SourceIndexUnique> listByDatabase(String sourceCatalogName, String sourceDatabaseName);
    
    @Query("FROM SourceIndexUnique WHERE sourceCatalogName = :sourceCatalogName AND sourceDatabaseName = :sourceDatabaseName AND sourceTableName = :sourceTableName")
    List<SourceIndexUnique> listByTable(String sourceCatalogName, String sourceDatabaseName, String sourceTableName);
}